<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>开关灯</title>
</head>
<body>
    <img src="../../png/bulboff.png" alt="图片正在加载..." id="myImg">
    <br>
    <button onclick="changeImg()">点击</button>
</body>
    <script>
        function changeImg(){
            var obj=document.getElementById("myImg")
            // if (obj.src=='http://localhost:63342/MyProject02/png/bulboff.png'){
            if(obj.src.search("bulboff")!=-1){
                obj.src="../../png/bulbon.png"
            }else{
                obj.src='../../png/bulboff.png'
            }
        }
    </script>
</html>